package com.xinqi.modules.course.clazz.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.repo.SuperMapper;
import com.xinqi.modules.course.clazz.domain.ClassGroupStudentEntity;
import com.xinqi.modules.course.clazz.dto.req.ClassGroupSignQueryDTO;
import com.xinqi.modules.course.clazz.dto.req.ClassGroupStudentQueryDTO;
import com.xinqi.modules.course.clazz.dto.rsp.ClassGroupResultDTO;
import com.xinqi.modules.course.clazz.dto.rsp.ClassGroupStudentResultDTO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 班级分组人员表数据层
 *
 * @author: system
 * @date: 2023/01/17
 */
@Mapper
public interface ClassGroupStudentMapper extends SuperMapper<ClassGroupStudentEntity> {

    List<ClassGroupStudentResultDTO> findStudentList(@Param("query") ClassGroupStudentQueryDTO query);

    IPage<ClassGroupStudentResultDTO> findStudentPageList(Page<ClassGroupStudentEntity> page, @Param("query") ClassGroupStudentQueryDTO query);

    Integer findClassTotalStudentCount(@Param("classId") Long classId);

    List<ClassGroupStudentResultDTO> findByPidAndSign(@Param("query") ClassGroupSignQueryDTO query);

    ClassGroupStudentResultDTO findByPidAndStudentId(@Param("id") Long pid, @Param("userId") Long userId);

    @MapKey("pid")
    Map<Long, Integer> findInsideGroupStudentCountByGroups(@Param("classId") Long classId, @Param("groups") List<ClassGroupResultDTO> groups);

    List<ClassGroupStudentResultDTO> findStudentListByGroupIds(@Param("groupIds") List<Long> groupIds);
}
